<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column align="center" label="订单编号" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="类型" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.businessTypeName }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="费用" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.freight }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="系统费用" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.systemFee }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="取件地址" width="240">
        <template slot-scope="scope">
          <span>{{ scope.row.takeAddressDetails }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="取件联系电话" width="110">
        <template slot-scope="scope">
          <span v-if="scope.row.takeMobile>0">{{ scope.row.takeMobile }}</span>
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="收货地址" width="240">
        <template slot-scope="scope">
          <span>{{ scope.row.deliveryAddressDetails }}</span>
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="收货联系电话" width="110">
        <template slot-scope="scope">
          <span>{{ scope.row.deliveryMobile }}</span>
        </template>
      </el-table-column>
      <el-table-column width="180px" align="center" label="订单时间">
        <template slot-scope="scope">
          <span>{{ scope.row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { fetchList } from "@/api/menu-order";
import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination

export default {
  name: "OrderList",
  components: { Pagination },
  data() {
    return {
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        pageIndex: 1,
        pageSize: 20
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.listLoading = true;
      fetchList(this.listQuery).then(response => {
        this.list = response.data.data;
        this.total = response.data.total;
        this.listLoading = false;
      });
    }
  }
};
</script>

<style scoped>
.edit-input {
  padding-right: 100px;
}
.cancel-btn {
  position: absolute;
  right: 15px;
  top: 10px;
}
</style>
